package com.lc.hot100.lc118;

import java.util.*;

public class Main {
	public static void main(String[] args) {
		
	}
}

class Solution {
    public List<List<Integer>> generate(int numRows) {
        List<List<Integer>> res = new ArrayList<List<Integer>>();
        int[][] table = new int[numRows][numRows];
        
        for (int i = 0; i < numRows; i ++) {
        	List<Integer> list = new ArrayList<>();
        	for (int j = 0; j <= i; j ++) {
        		if (j == 0 || j == i) {
        			table[i][j] = 1;
        		} else {
        			table[i][j] = table[i - 1][j - 1] + table[i - 1][j];
        		}
        		list.add(table[i][j]);
        	}
        	res.add(list);
        }
    	
    	return res;
    }
}
